<?php
/**
 * Yii view column
 *
 * @author luubk
 * @since May 18, 2013 - 8:38:50 PM
 */
?>
<?php $this->beginContent('//layouts/main'); ?>
<!--Header Start-->
<div class="header" >

    <a href="<?php echo Yii::app()->params['adminHomeUrl'] ?>" class="logo">
        <h1><?php echo Yii::app()->name ?></h1>
    </a>

    <div class="pull-right">

        <!--Notifications Start-->  
        <div class="notifications-head">

            <!--Messages Start-->
            <div class="btn-group m_left hide-mobile hide" >
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <span class="notification">531</span><span class="triangle-1"></span><i class="icon-comments"></i><span class="caret"></span>
                </a>
                <div class="dropdown-menu">

                    <span class="triangle-2"></span>
                    <div class="ichat">
                        <div class="ichat-messages">
                            <div class="ichat-title">
                                <div class="pull-left">New Messages</div>
                                <div class="pull-right"><span>Update 4*</span></div>
                                <div class="clear"></div>
                            </div>

                            <div class="imessage">
                                <div class="iavatar"><img src="<?php echo $this->asset ?>/images/users/1.jpg" alt=""></div>
                                <div class="imes">
                                    <div class="iauthor">Alan Cook</div>
                                    <div class="itext">All right. Thank you.</div>
                                </div>
                                <div class="idelete"><a href="#"><span><i class="icon-remove"></i></span></a></div>
                                <div class="clear"></div>
                            </div>
                            <div class="imessage">
                                <div class="iavatar"><img src="<?php echo $this->asset ?>/images/users/6.jpg" alt=""></div>
                                <div class="imes">
                                    <div class="iauthor">Emma Clark</div>
                                    <div class="itext">Will you pay by credit card?</div>
                                </div>
                                <div class="idelete"><a href="#"><span><i class="icon-remove"></i></span></a></div>
                                <div class="clear"></div>
                            </div>
                            <div class="imessage">
                                <div class="iavatar"><img src="<?php echo $this->asset ?>/images/users/2.jpg" alt=""></div>
                                <div class="imes">
                                    <div class="iauthor">Blake Washington</div>
                                    <div class="itext">Can I help you?</div>
                                </div>
                                <div class="idelete"><a href="#"><span><i class="icon-remove"></i></span></a></div>
                                <div class="clear"></div>
                            </div>

                            <div class="ichat-link"><a href="#">InBox</a> <a href="#">OutBox</a> <a href="#">Spam</a> <a href="#">Trash</a>
                                <div class="clear"></div>
                            </div>

                        </div>
                        <a href="#" class="iview">View all</a><a href="#" class="imark">Mark all read</a>

                    </div>

                </div>
            </div>
            <!--Messages END--> 

            <!--Recent Activity Start-->
            <div class="btn-group pull-left hide-mobile" >
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <span class="notification hide">77</span><span class="triangle-1 hide"></span>
                    <i class="icon-bell"></i><span class="caret"></span>
                </a>
                <div class="dropdown-menu">

                    <span class="triangle-2"></span>
                    <div class="ichat">
                        <div class="ichat-messages">
                            <div class="ichat-title">
                                <div class="pull-left">
                                    <?php echo Yii::t('activity', 'Recent Activity') ?>
                                </div>
                                <div class="pull-right"></div>
                                <div class="clear"></div>
                            </div>

                            <div class="r_activity">
                                <?php
                                $iconArray = array(
                                    'delete' => 'remove',
                                    'update' => 'edit',
                                    'create' => 'plus',
                                        )
                                ?>
                                <?php foreach (Activity::getTop(3) as $activity): ?>
                                    <div class="imessage">
                                        <div class="r_icon">
                                            <a href="<?php echo $activity->type != 'delete' ? $activity->url : '#' ?>">
                                                <i class="icon-<?php echo @$iconArray[$activity->type] ?>"></i>
                                            </a>
                                        </div>
                                        <div class="r_info">
                                            <div class="r_name">
                                                <strong><?php echo @$activity->admin->username ?></strong> 
                                                <?php echo Yii::t("activity", $activity->type) ?>
                                                <?php echo Yii::t(strtolower($activity->object_type), $activity->object_type) ?>: 
                                                <?php echo $activity->object_name ?>
                                            </div>
                                            <div class="r_text">
                                                <i class="icon-time"></i> 
                                                <?php echo MyUtil::timeToString($activity->created_at) ?>
                                            </div>
                                            <?php if ($activity->type != 'delete'): ?>
                                                <div class="r_link">
                                                    <a href="<?php echo $activity->url ?>">
                                                        <?php echo Yii::t('activity', 'View') ?>...
                                                    </a>
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                        <div class="clear"></div>
                                    </div>
                                <?php endforeach ?>
                            </div>
                        </div>
                        <a href="<?php echo Activity::viewAllUrl(); ?>" 
                           class="iview"><?php echo Yii::t('activity', 'View all') ?></a>
                        <!--<a href="#" class="imark hide">Mark all read</a>-->
                    </div>

                </div>
            </div>
            <!--Recent Activity END--> 

        </div><!--Notifications END-->

        <?php if ($this->user != NULL): ?>
            <!--Button User Start-->  
            <div class="btn-group pull-right" >                        
                <a class="btn btn-profile"
                   href="<?php echo Yii::app()->homeUrl ?>"  style="border: 0" target="_blank">
                    <span class="name-user">
                        <?php echo Yii::t('main', 'Home') ?>                                
                    </span>                             
                </a>
            </div>
            <div class="btn-group pull-right" >
                <a class="btn btn-profile dropdown-toggle" id="button-profile" data-toggle="dropdown" href="#">
                    <span class="name-user">
                        <?php echo $this->user->username ?>
                    </span> 
                    <span class="avatar">
                        <img src="<?php echo $this->asset ?>/images/users/luubk.png" alt="" >
                    </span> 
                    <span class="caret"></span>
                </a>
                <div class="dropdown-menu" id="prof_dropdown">
                    <div class="item_m"><span class="caret"></span></div>
                    <ul class="clear_ul" >
                        <li>
                            <a href="<?php echo Yii::app()->homeUrl ?>" target="_blank">
                                <i class="icon-globe"></i>
                                <?php echo Yii::t('main', 'Home') ?>
                            </a>
                        </li>
                        <li>
                            <a href="<?php echo Admin::changePassUrl() ?>">
                                <i class="icon-lock"></i>
                                <?php echo Yii::t('adminuser', 'Change Password') ?>
                            </a>
                        </li>
                        <!--                                <li>
                                                            <a href="#">
                                                                <i class="icon-cog"></i>
                        <?php echo Yii::t('user', 'Setting') ?>
                                                            </a>
                                                        </li>-->
                        <li>
                            <a href="<?php echo $this->createUrl('default/logout', array('lang' => $this->lang)) ?>">
                                <i class="icon-off"></i> 
                                <?php echo Yii::t('user', 'Sign Out') ?>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
            <!--Button User END-->  
        <?php endif; ?>


        <!--Button Language Start -->  
        <div class="btn-group pull-right" >
            <a class="btn btn-profile dropdown-toggle" data-toggle="dropdown" href="#">
                <span class="avatar" style="border: 0">
                    <img src="<?php echo $this->asset ?>/images/flags/<?php echo Yii::app()->language ?>.png" alt="" >
                </span> 
                <span class="caret"></span>
            </a>
            <div class="dropdown-menu" id="prof_dropdown">
                <div class="item_m"><span class="caret"></span></div>
                <ul class="clear_ul" >
                    <?php $route = Yii::app()->controller->id . "/" . Yii::app()->controller->action->id ?>
                    <?php
                    foreach (Language::getAllArray() as $langCode => $langName):
                        ?>
                        <li>
                            <a href="<?php echo $this->createUrl($route, array('lang' => $langCode)) ?>">
                                <img src="<?php echo $this->asset . "/images/flags/$langCode.png"; ?>" /> 
                                <?php echo $langName ?>
                            </a>
                        </li>
                    <?php endforeach; ?>                            
                </ul>
            </div>
        </div>
        <!--Button Language END-->  

    </div>
</div>
<!--Header END-->


<!--Sidebar Start--> 
<div id="sidebar" class="tooltip-right">
    <?php
    $this->widget('SidebarMenu', array(
        'activeCssClass' => 'active',
        'items' => $this->sidebarMenu,
        'htmlOptions' => array(
            'class' => 'menu-sidebar typeSidebar'
        ),
    ));
    ?>            
</div>
<script>
    $(window).scroll(function() {
        if ($(this).scrollTop() >= 45) {
            $('.typeSidebar').addClass("position-fx");
        }
        if ($(this).scrollTop() < 45) {
            $('.typeSidebar').removeClass("position-fx");
        }

    });
</script>
<!--Sidebar END-->

<!--Content Start-->
<div id="content">
    <!--SpeedBar Start-->
    <div class="speedbar">
        <div class="speedbar-content">
            <?php if (!empty($this->sidebarMenu)): ?>
                <ul class="menu-drop">
                    <li>
                        <a href="#"><i class="icon-chevron-down"></i></a>
                        <ul>
                            <?php
                            foreach ($this->sidebarMenu as $item)
                            {
                                if (!isset($item['url']) OR !isset($item['label']))
                                    continue;
                                echo "<li>";
                                echo CHtml::link($item['label'], $item['url']);
                                echo "</li>";
                            }
                            ?>
                        </ul>  
                    </li>
                </ul>
            <?php endif; ?>
            <?php
            $this->widget('OpendevMenu', array(
                'activeCssClass' => 'act_link',
                'items' => $this->controllerMenu,
                'htmlOptions' => array(
                    'class' => 'menu-speedbar'
                ),
            ));
            ?>
        </div>
    </div>
    <!--SpeedBar END-->

    <!--Search Start-->   
    <div class="search">               
        <?php $route = Yii::app()->controller->id . "/search" ?>
        <form class="search-form" action="<?php echo Yii::app()->controller->createUrl($route, array('lang' => Yii::app()->language)) ?>">
            <?php foreach ($_GET as $getkey => $getval): ?>
                <input type="hidden" name="<?php echo $getkey ?>" value="<?php echo $getval ?>" />
            <?php endforeach; ?>
            <input type="text" name="key" value="<?php echo isset($_GET['key']) ? $_GET['key'] : '' ?>"
                   placeholder="<?php echo Yii::t('main', 'Enter keywords') ?>">
        </form>
        <div class="clear"></div>	
    </div>
    <!--Search END-->

    <!--CONTENT MAIN START-->
    <div class="content" style="min-height: 350px">
        <div class="clear"></div>
        <?php if (Yii::app()->user->hasFlash('Notify')): ?>
            <div class="alert alert-info">
                <button type="button" class="close" data-dismiss="alert">×</button>
                <strong><?php echo Yii::t('main', 'Notify') ?></strong> 
                <?php echo Yii::app()->user->getFlash('Notify') ?>
            </div>
        <?php endif; ?>
        <div class="clear"></div>
        <div class="row-fluid">
            <?php echo $content ?>
        </div>
    </div>
    <!--CONTENT MAIN END-->

</div>
<!--Content END-->
<?php $this->endContent(); ?>